<?php

class segmentoComponent extends Component{
    
    public function listar($model, $itens, $title = "", $class = ''){
        
        if(!is_array($itens) ||empty ($itens)) return;
        $this->opendiv("segmentos");
            //$this->title("Segmentos onde a TENAP atua");
            //$this->subtitle("Veja a lista de todos os segmentos do mercado onde a TENAP já fez obras");
            $this->LoadComponent("galeria/album", 'galbum');
            foreach($itens as $it){
                extract($it);
                $capa = $this->galbum->getLinkCapa($album, "medium", false);
                $capa = "<img src='$capa'/>";
                $html = "<h3>$catnome</h3><p>$capa</p>";
                $link = "tenap/segmento/show/$cod_categoria/". GetPlainName($catnome);
                $this->AddItem($link, $html, "segm");
            }
        $this->closediv();
    }
    
    public function show($model, $item){
        if(empty ($item)) return;
        
        extract($item);
        
        $this->linksnav(array(
                'Portfólio'         => 'tenap/portfolio', 
                $catnome => ''
        ));
        
        $this->LoadJsPlugin("galerias/lightbox", 'lb');
        //$this->LoadJsPlugin("galerias/cloudzoom", 'czoom');
        $this->LoadJsPlugin('slider/easyslider', 'slider');
        $this->LoadComponent("galeria/album", 'galbum');
        $this->lb->start('conteudo');
        $this->lb->start('box');
        $this->lb->start('gallery');
        
        $this->opendiv("", "obras");
            $this->title($catnome);
            $this->clear(); 
            $this->opendiv("boxpai");
                $this->slider->setTitle("");
                $this->slider->drawFotos($album, 'gal', '', 'box');
                $this->galbum->drawAlbum($album, "", 'gallery', false, 'medium',"");
             $this->closediv();
            $this->clear();
             //$this->czoom->drawGallery($album, "czoom");
             
            $totalde_nome = ($catnome == "Projetos")?"Projetos":"Obras";
             if(!empty ($item['clientes'] )){
                 $this->opendiv("clientes");
                 $this->subtitle("Clientes deste segmento");
                 foreach($item['clientes'] as $it){
                     extract($it);
                     //$capa = $this->galbum->getLinkCapa($album, "min", true);
                     //$capa = "<img src='$capa'/>";
                     //$html = "$capa<h3>$nome</h3><p>Total de Obras: $total</p>";
                     $html = "<h3>$nome</h3><span>Total de $totalde_nome: $total</span>";
                     $link = "tenap/cliente/show/$cod_cliente/". GetPlainName($nome);
                     $this->AddItem($link, $html, "cli");
                 }
                 $this->closediv();
             }
        $this->closediv();
        $this->clear();
        
        $this->LoadResource('html/paginator', 'pag');
        $this->pag->draw();
    }
    
    
}

?>

<style type="text/css">
    #boxpai{
        height: 250px;
        overflow: hidden;
        width: 100%;
    }
            .box{
                float: left;
                height: 250px;
                width: 250px;
            }
            .box img{height: 230px !important; width: 230px !important; }
            
            .gallery img{height: 105px !important; width: 105px !important;}
</style>

<style type="text/css">
    .obras img{
        float: left;
        height: 100px;
        margin: 10px;
    }
    
    #clientes{
        font-size: 14px;
        margin: 20px 0;
        overflow: auto;
        text-align: left;
    }
    
            .cli{
                background: #f6f6f6;
                cursor: pointer;
                float: left;
                height: 60px;
                margin: 5px;
                min-width: 220px;
                overflow: hidden;
                width: 24%;

            }

            .cli:hover{
                background: #d6d6d6;
            }

                    .cli img{
                        margin: 0 10px 0 0;
                        padding: 0;
                        height: 80px;
                        width: 80px;
                    }   
</style>

<style type="text/css">
    #segmentos{
        overflow: auto;
    }
    
    .segm{
        background: #f6f6f6;
        float: left;
        height: 150px;
        margin: auto;
        margin: 0 6px 6px 0;
        min-width: 165px;
        overflow: hidden;
        position:relative;
        text-align: center;
        width: 32%;
    }
    
    .segm:hover{
        background: #d6d6d6;
    }
    
    .segm img{
        height: 110px;
        left:50%;
        margin-left: -60px;
        margin-bottom: 30px;
        position:absolute;
    }    
    
</style>